package hot100;

import comment.TreeNode;

/**
 * @Author: wzp
 * @CreateTime: 2024-09-14  10:18
 * @Description: 翻转二叉树
 * @Version: 1.0
 */
public class hot_226 {
    public TreeNode invertTree(TreeNode root) {
        dfs(root);
        return root;
    }

    public void dfs(TreeNode root){
        if(root==null){
            return;
        }
        TreeNode newNode;
        newNode=root.left;
        root.left=root.right;
        root.right=newNode;
        dfs(root.left);
        dfs(root.right);
    }

}
